|
|
|
|
|
|
|
the individual drawings in a cartoon. You typically use the Animation control to indicate that a task is in progress, such as the File, Copy routine of Windows, shown in Figure 12.34. These animations run in the background while other tasks are performed. |
|
|
|
|
|
|
|
|
Figure 12.34
A copy in progress is
indicated by a simple animation. |
|
|
|
|
|
|
|
|
|
Another way to create simple animation effects might be to use a Timer control to change the position of an Image control at a specified interval. Although this method requires a little more coding than is necessary with the Animation control, you do not need to have your animation already saved in an AVI file. The Timer control is covered in Chapter 4, "Using Visual Basic's Default Controls."  |
|
|
|
|
|
|
|
|
|
|
Setting Up the Animation Control |
|
|
|
|
|
|
|
|
To set up an Animation control, first add an instance of the control by drawing it on the form. Figure 12.35 shows the initial appearance of the Animation control. |
|
|
|
|
|
|
|
|
Figure 12.35
The Animation control initially looks like a
picture box with a reel of film in the middle. |
|
|
|
|
|
|
|
|
Drawing the Animation control on the form provides the container for the animation sequence. However, to run an animation, you need to open a file and start playback. |
|
|
|
|
|
|
|
|
You can do this by adding a command button to your form and writing code in the Click event to open and play a video file. |
|
|
|
|
|
|
|
|
To open a file, use the Open method of the Animation control, specifying the path to the desired AVI file. (Several AVI videos are included in the \Graphics\Videos directory, if you chose to install them.) After you open an AVI file, execute the Play method to start the animation. The following two lines of code play an AVI file: |
|
|
|
|
|
|
|
|
Animation1.Open "C:\Progra~1\Micros~1\Common\Graphics\Videos\FileNuke.Avi"
Animation1.Play |
|
|
|
|
|
|
|
|
Figure 12.36 shows the control during playback. To stop the animation, simply use the Stop method of the control. |
|
|
|
|
|